<?php
if(!defined('____PageInfo_php____')){
	define('____PageInfo_php____',true);
	Class PageInfo{

		public $totalRows;

		public $totalPages;

		public $pageSize;

		public $pageNumber;

		public $data;

		public $showPages;

		public $prePageNumber;
		public $nextPageNumber;


		
		function ProduceShowPagesInfo($ps){
			if($ps<1){
				return;
			}

			if($this->pageNumber<$this->totalPages){
				$this->nextPageNumber=$this->pageNumber+1;
			}
			else{
				$this->nextPageNumber=$this->totalPages;
			}

			if($this->pageNumber>1){
				$this->prePageNumber=$this->pageNumber-1;
			}
			else{
				$this->prePageNumber=1;
			}
			//	echo "ps:".$ps."<br //>";
			

			$this->showPages=array();
			$temph=array();
			$tempt=array();
			for($i1=0,$i2=0,$i3=0;($i1+$i2)<$ps&&$i3<$ps;$i3++){
				if(($this->pageNumber-$i1)>=1){

					$temph[$i1]=$this->pageNumber-$i1;
					//echo "temph:".$temph[$i1]." ,i1:".$i1."<br //>";
					$i1++;
				}
				if(($this->pageNumber+$i2+1)<=$this->totalPages){

					$tempt[$i2]=$this->pageNumber+$i2+1;
					$i2++;
				}


				//echo "i1:".$i1." i2:".$i2."<br //>";

				//echo "temph:".$temph[$i1]." tempt:".$tempt[$i2]."<br //>";
			}
			//echo "count:".count($tempa)."<br //>";

			for($i4=$i1-1,$i3=0;$i4>=0;$i4--,$i3++){
				$this->showPages[$i3]=$temph[$i4];
				//echo "sps:".$this->showPages[$i3]. " ,i3:".$i3. " ,i4:".$i4."<br //>";
				//echo "temph:".$temph[$i4]." ,i4:".$i4."<br //>";
			}
			for($i4=0;$i4<$i2;$i4++,$i3++){
				$this->showPages[$i3]=$tempt[$i4];
				//echo "sps:".$showPages[$i3]."<br //>";
			}
		}
	}
}
?>